<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>GTK's rc File Format</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="GTK+ 2.0 Tutorial"
HREF="book1.html"><LINK
REL="UP"
TITLE="GTK's rc Files"
HREF="c2118.html"><LINK
REL="PREVIOUS"
TITLE="GTK's rc Files"
HREF="c2118.html"><LINK
REL="NEXT"
TITLE="Example rc file"
HREF="x2179.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GTK+ 2.0 Tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="c2118.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>GTK's rc Files</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x2179.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SEC-GTKSRCFILEFORMAT"
>GTK's rc File Format</A
></H1
><P
>The format of the GTK file is illustrated in the example below. This is
the testgtkrc file from the GTK distribution, but I've added a
few comments and things. You may wish to include this explanation in
your application to allow the user to fine tune his application.</P
><P
>There are several directives to change the attributes of a widget.</P
><P
></P
><UL
><LI
><P
>fg - Sets the foreground color of a widget.</P
></LI
><LI
><P
>bg - Sets the background color of a widget.</P
></LI
><LI
><P
>bg_pixmap - Sets the background of a widget to a tiled pixmap.</P
></LI
><LI
><P
>font - Sets the font to be used with the given widget.</P
></LI
></UL
><P
>In addition to this, there are several states a widget can be in, and you
can set different colors, pixmaps and fonts for each state. These states are:</P
><P
></P
><UL
><LI
><P
>NORMAL - The normal state of a widget, without the mouse over top of
it, and not being pressed, etc.</P
></LI
><LI
><P
>PRELIGHT - When the mouse is over top of the widget, colors defined
using this state will be in effect.</P
></LI
><LI
><P
>ACTIVE - When the widget is pressed or clicked it will be active, and
the attributes assigned by this tag will be in effect.</P
></LI
><LI
><P
>INSENSITIVE - When a widget is set insensitive, and cannot be
activated, it will take these attributes.</P
></LI
><LI
><P
>SELECTED - When an object is selected, it takes these attributes.</P
></LI
></UL
><P
>When using the "fg" and "bg" keywords to set the colors of widgets, the
format is:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>fg[&#60;STATE&#62;] = { Red, Green, Blue }</PRE
></TD
></TR
></TABLE
><P
>Where STATE is one of the above states (PRELIGHT, ACTIVE, etc), and the Red,
Green and Blue are values in the range of 0 - 1.0,  { 1.0, 1.0, 1.0 } being
white. They must be in float form, or they will register as 0, so a straight 
"1" will not work, it must be "1.0".  A straight "0" is fine because it 
doesn't matter if it's not recognized.  Unrecognized values are set to 0.</P
><P
>bg_pixmap is very similar to the above, except the colors are replaced by a
filename.</P
><P
>pixmap_path is a list of paths separated by ":"'s.  These paths will be
searched for any pixmap you specify.</P
><P
>The font directive is simply:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>font = "&#60;font name&#62;"</PRE
></TD
></TR
></TABLE
><P
>The only hard part is figuring out the font string. Using xfontsel or
a similar utility should help.</P
><P
>The "widget_class" sets the style of a class of widgets. These classes are
listed in the widget overview on the class hierarchy.</P
><P
>The "widget" directive sets a specifically named set of widgets to a
given style, overriding any style set for the given widget class.
These widgets are registered inside the application using the
gtk_widget_set_name() call. This allows you to specify the attributes of a
widget on a per widget basis, rather than setting the attributes of an
entire widget class. I urge you to document any of these special widgets so
users may customize them.</P
><P
>When the keyword <TT
CLASS="LITERAL"
>parent</TT
> is used as an attribute, the widget will take on
the attributes of its parent in the application.</P
><P
>When defining a style, you may assign the attributes of a previously defined
style to this new one.</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>style "main_button" = "button"
{
  font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
  bg[PRELIGHT] = { 0.75, 0, 0 }
}</PRE
></TD
></TR
></TABLE
><P
>This example takes the "button" style, and creates a new "main_button" style
simply by changing the font and prelight background color of the "button"
style.</P
><P
>Of course, many of these attributes don't apply to all widgets. It's a
simple matter of common sense really. Anything that could apply, should.</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="c2118.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x2179.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>GTK's rc Files</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c2118.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Example rc file</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>